﻿//-----------------------------------------------------------------------------
// <copyright file="FakeDisplayMessage.cs" company="William E. Kempf">
//     Copyright (c) William E. Kempf.
// </copyright>
//-----------------------------------------------------------------------------

namespace SimpleTest.TestArtifacts
{
    using System;
    using System.Windows;
    using Onyx.Windows;
    using Testing.Specificity;

    /// <summary>
    /// Provides a "test fake" for the <see cref="IDisplayMessage"/> interface.
    /// </summary>
    internal class FakeDisplayMessage : IDisplayMessage
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="FakeDisplayMessage"/> class.
        /// </summary>
        public FakeDisplayMessage()
        {
            this.ShowMessage = (t, c, b, i, r, o) => default(MessageBoxResult);
        }

        /// <summary>
        /// Delegate definition for the ShowMessage method.
        /// </summary>
        /// <param name="messageBoxText">A <see cref="String"/> that specifies the text to display.</param>
        /// <param name="caption">A <see cref="String"/> that specifies the title bar caption to display.</param>
        /// <param name="button">A <see cref="MessageBoxButton"/> value that specifies which button or buttons to display.</param>
        /// <param name="icon">A <see cref="MessageBoxImage"/> value that specifes the icon to display.</param>
        /// <param name="defaultResult">A <see cref="MessageBoxResult"/> value that specifies the default result of the message box.</param>
        /// <param name="options">A <see cref="MessageBoxOptions"/> value object that specifies the options.</param>
        /// <returns>
        /// A <see cref="MessageBoxResult"/> value that specifies which message box button was clicked by the user.
        /// </returns>
        public delegate MessageBoxResult ShowMessageDelegate(
            string messageBoxText,
            string caption,
            MessageBoxButton button,
            MessageBoxImage icon,
            MessageBoxResult defaultResult,
            MessageBoxOptions options);

        /// <summary>
        /// Gets or sets a delegate that's called when <see cref="IDisplayMessage.ShowMessage"/> is called on the fake.
        /// </summary>
        public ShowMessageDelegate ShowMessage { get; set; }

        /// <summary>
        /// Displays a message to the user, typically as a message box.
        /// </summary>
        /// <param name="messageBoxText">A <see cref="String"/> that specifies the text to display.</param>
        /// <returns>
        /// A <see cref="MessageBoxResult"/> value that specifies which message box button was clicked by the user.
        /// </returns>
        MessageBoxResult IDisplayMessage.ShowMessage(string messageBoxText)
        {
            return ((IDisplayMessage)this).ShowMessage(messageBoxText, null);
        }

        /// <summary>
        /// Displays a message to the user, typically as a message box.
        /// </summary>
        /// <param name="messageBoxText">A <see cref="String"/> that specifies the text to display.</param>
        /// <param name="caption">A <see cref="String"/> that specifies the title bar caption to display.</param>
        /// <returns>
        /// A <see cref="MessageBoxResult"/> value that specifies which message box button was clicked by the user.
        /// </returns>
        MessageBoxResult IDisplayMessage.ShowMessage(string messageBoxText, string caption)
        {
            return ((IDisplayMessage)this).ShowMessage(messageBoxText, caption, MessageBoxButton.OK);
        }

        /// <summary>
        /// Displays a message to the user, typically as a message box.
        /// </summary>
        /// <param name="messageBoxText">A <see cref="String"/> that specifies the text to display.</param>
        /// <param name="caption">A <see cref="String"/> that specifies the title bar caption to display.</param>
        /// <param name="button">A <see cref="MessageBoxButton"/> value that specifies which button or buttons to display.</param>
        /// <returns>
        /// A <see cref="MessageBoxResult"/> value that specifies which message box button was clicked by the user.
        /// </returns>
        MessageBoxResult IDisplayMessage.ShowMessage(string messageBoxText, string caption, MessageBoxButton button)
        {
            return ((IDisplayMessage)this).ShowMessage(messageBoxText, caption, button, MessageBoxImage.None);
        }

        /// <summary>
        /// Displays a message to the user, typically as a message box.
        /// </summary>
        /// <param name="messageBoxText">A <see cref="String"/> that specifies the text to display.</param>
        /// <param name="caption">A <see cref="String"/> that specifies the title bar caption to display.</param>
        /// <param name="button">A <see cref="MessageBoxButton"/> value that specifies which button or buttons to display.</param>
        /// <param name="icon">A <see cref="MessageBoxImage"/> value that specifes the icon to display.</param>
        /// <returns>
        /// A <see cref="MessageBoxResult"/> value that specifies which message box button was clicked by the user.
        /// </returns>
        MessageBoxResult IDisplayMessage.ShowMessage(string messageBoxText, string caption, MessageBoxButton button, MessageBoxImage icon)
        {
            return ((IDisplayMessage)this).ShowMessage(messageBoxText, caption, button, icon, MessageBoxResult.OK);
        }

        /// <summary>
        /// Displays a message to the user, typically as a message box.
        /// </summary>
        /// <param name="messageBoxText">A <see cref="String"/> that specifies the text to display.</param>
        /// <param name="caption">A <see cref="String"/> that specifies the title bar caption to display.</param>
        /// <param name="button">A <see cref="MessageBoxButton"/> value that specifies which button or buttons to display.</param>
        /// <param name="icon">A <see cref="MessageBoxImage"/> value that specifes the icon to display.</param>
        /// <param name="defaultResult">A <see cref="MessageBoxResult"/> value that specifies the default result of the message box.</param>
        /// <returns>
        /// A <see cref="MessageBoxResult"/> value that specifies which message box button was clicked by the user.
        /// </returns>
        MessageBoxResult IDisplayMessage.ShowMessage(string messageBoxText, string caption, MessageBoxButton button, MessageBoxImage icon, MessageBoxResult defaultResult)
        {
            return ((IDisplayMessage)this).ShowMessage(messageBoxText, caption, button, icon, defaultResult, MessageBoxOptions.None);
        }

        /// <summary>
        /// Displays a message to the user, typically as a message box.
        /// </summary>
        /// <param name="messageBoxText">A <see cref="String"/> that specifies the text to display.</param>
        /// <param name="caption">A <see cref="String"/> that specifies the title bar caption to display.</param>
        /// <param name="button">A <see cref="MessageBoxButton"/> value that specifies which button or buttons to display.</param>
        /// <param name="icon">A <see cref="MessageBoxImage"/> value that specifes the icon to display.</param>
        /// <param name="defaultResult">A <see cref="MessageBoxResult"/> value that specifies the default result of the message box.</param>
        /// <param name="options">A <see cref="MessageBoxOptions"/> value object that specifies the options.</param>
        /// <returns>
        /// A <see cref="MessageBoxResult"/> value that specifies which message box button was clicked by the user.
        /// </returns>
        MessageBoxResult IDisplayMessage.ShowMessage(
            string messageBoxText,
            string caption,
            MessageBoxButton button,
            MessageBoxImage icon,
            MessageBoxResult defaultResult,
            MessageBoxOptions options)
        {
            return this.ShowMessage(messageBoxText, caption, button, icon, defaultResult, options);
        }
    }
}
